package club.banyuan.oop.VideoDemo;

import java.util.Arrays;

/**
 * @author edz
 * @version 1.0
 * @date 2020/11/19 下午5:01
 */
public class VideoStore {

    Video[]videos=new Video[3];
    Video video=new Video();
    //添加一个新电影

    public void addVideo(String name){
        for (int i = 0; i <videos.length ; i++) {
        if(videos[i].getName().equals(name)){
            System.err.println(name+"已存在");
        }else{
            videos=Arrays.copyOf(videos,videos.length+1);
            videos[videos.length-1]=video;
            break;
        }
        }
    }

    public boolean checkOut(String name){
        for (int i = 0; i <videos.length ; i++) {

        if(videos[i].getName().equals(name)&&video.getMarking()==false){
            videos[i].setName(null);
            return true;
        }else{
            System.err.println(name+"已被租出");
        }
        }
        return false;
    }







}
